//
//  Product.m
//  CodeKatas
//
//  Created by Viktor Lazarevich on 27-Feb-10.
//  Copyright 2010 Home. All rights reserved.
//

#import "Product.h"
#import "PricingStrategy.h"
#import "SimplePricing.h"

@implementation Product

- (id)initWithCode: (NSString *)code andPrice: (id)price {
	if (![price conformsToProtocol:@protocol(PricingStrategy)]) {
		[self release];
		return nil;
	}
	
	if (self = [super init]) {
		productCode = code;
		productPrice = price;
	}
	
	return self;
}

-(id)init {
	SimplePricing *price = [[SimplePricing alloc] init];
	return [self initWithCode:@"EMPTY" andPrice:price];
}


- (Money)getPriceFor: (Quantity)quantity {
	return [productPrice getPriceFor:quantity];
}
@end
